package com.amigo.online.provider.video.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.common.param.dto.video.VideoCommentQueryDto;
import com.amigo.online.provider.video.model.entity.VideoComment;

@Mapper
@Component
public interface VideoCommentMapper extends MyMapper<VideoComment> {

    List<VideoComment> selectByVideoId(VideoCommentQueryDto videoCommentQueryDto);

    int deleteComment(@Param("id") Long id);

    @Select("SELECT  vc.id AS id, vc.video_id AS video_id, vc.user_id AS user_id, vc.content AS content,"
            + " vc.status AS status, vc.created_time AS created_time ,vc.comment_id AS comment_id,"
            + " vc.type AS type , a.user_name as nickname, a.user_avatar as avatar"
            + " from video_comment_tbl vc LEFT JOIN adv_recommend_video_tbl a  on vc.video_id = a.id"
            + " WHERE vc.status = 1 AND vc.video_id = #{id} and vc.is_adv = 1"
            + " ORDER BY vc.created_time desc limit #{offset},#{limit} ")
    List<VideoComment> selectByAdvVideoId(@Param("id") int videoId, @Param("offset") int offset, @Param("limit") int limit);
}
